package com.exigen.performance.test.webapp.dao;

import java.util.List;

import javax.persistence.Query;

import com.exigen.performance.test.webapp.domain.TransactionEntity;
import com.exigen.performance.test.webapp.domain.base.GenericJPADAO;

/**
 * Class that handles TransactionEntity selection from database;
 * 
 * @author Maksim Savchuk
 * 
 */
public class TransactionJpaDao extends GenericJPADAO<TransactionEntity, Long>
		implements TransactionDao {

	private final String query1 = " select distinct t from TransactionEntity t, TestSummaryEntity s, TestResultsEntity r where t.id=r.transactionId and s.id=r.testSummaryId and s.id in(:testSummaryId)";

	public TransactionJpaDao() {
		super(TransactionEntity.class);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.exigen.performance.test.webapp.dao.TransactionDao#getTransactionList
	 * (java.lang.Long)
	 */
	public List<TransactionEntity> getTransactionList(List<Long> testSummaryId) {
		Query query = getEntityManager().createQuery(query1);
		query.setParameter("testSummaryId", testSummaryId);
		@SuppressWarnings("unchecked")
		List<TransactionEntity> result = query.getResultList();
		return result;

	}

}
